﻿using Leeder.Logger;
using NewAndong.Comm;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NewAndong.Forms
{
    public partial class FrmMaterialDirection : UIPage
    {
        bool isLoad = true;
        AutoSizeFormClass asc = new AutoSizeFormClass();
        public LogOperate LogObj => Log.GetLogger(this.GetType());

        public FrmMaterialDirection()
        {
            InitializeComponent();
        }

        private void FrmMaterialDirection_Load(object sender, EventArgs e)
        {
            if (!isLoad)
                return;
            isLoad = false;

            LoadDgvSYSetting();
        }

        private void LoadDgvSYSetting()
        {
            var settingList = GolbalVariable.DirectQuoteSettingBag.OrderBy(x => x.ID).ToList();
            foreach (var item in settingList)
            {
                item.UseStatus = item.IsUse == 0 ? "未启用" : "已启用";
                item.TypeName = item.Type == "SY" ? "顺引" : "出发链";
            }
            var syUseList = settingList.Where(w => w.Type == "SY" && w.IsUse == 1).ToList();
            //加载顺引页面
            for (int i = 0; i < syUseList.Count(); i++)
            {
                FrmMaterial frmMaterial = new FrmMaterial(syUseList[i].DirectName);
                tabControl.AddPage(frmMaterial);
                tabControl.TabPages[i].Text = syUseList[i].DirectName;
            }
        }
    }
}
